const BASE_URL = 'http://ymdcnode.sloxm.top'
// const BASE_URL = 'http://127.0.0.1:3007'
// const BASE_URL = 'http://192.168.0.105:3007'
// const BASE_URL = 'http://192.168.0.107:3007'

// console.log()
const token = ""
export const myRequest = (url = '', method, data) => {
  return new Promise((resolve, reject) => {
    uni.request({
      url: BASE_URL + url,
      method: method || 'GET',
      data: data || '',
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'Authorization': uni.getStorageSync('token') || ""
      },
      success: (res) => {
        // if (res.data.code === 401) {
        //   // console.log(res)
        //   return uni.navigateTo({
        //     url: '/pages/login/login'
        //   })
        // }
       
        if (res.data.status !== 200 && res.data.status !== 201) {
          console.log(res)
          return uni.showToast({
            title: '请求数据失败',
            icon:"error"
          })
        }
        resolve(res)


      },
      fail: (err) => {
        reject(err)
        return uni.showToast({
          title: '请求接口失败',
          icon:"error"
        })

      }
    })
  })
}
